<%@ Page Language="C#" Inherits="IBuyAdventure.PageBase" src="components/stdpage.cs" %>
<%@ Register TagPrefix="IBA" TagName="Header" Src="UserControl\Header.ascx" %>
<%@ Register TagPrefix="IBA" TagName="Footer" Src="UserControl\Footer.ascx" %>
<%@ Register TagPrefix="IBA" TagName="Categories" Src="UserControl\Categories.ascx" %>
<%@ Import Namespace="System.Data" %>
<%@ OutputCache Duration="600" VaryByParam="ProductType" %>

<HTML>
  <HEAD>
    <TITLE>IBuyAdventure Catalog</TITLE>
  </HEAD>
  
  <script language="C#" runat="server">

      void Page_Load(Object sender, EventArgs e) {
         // Determine what product category has been specified and update section image
         
         String productType = Request.Params["ProductType"]; 
         CatalogueSectionImage.Src = "images/hd_" + productType + ".gif";
         
         // User business object to fetch category products and databind
         // it to a <asp:datalist> control
         IBuyAdventure.ProductsDB inventory = new IBuyAdventure.ProductsDB(getConnStr());         
         MyList.DataSource = inventory.GetProducts(productType);
         MyList.DataBind();
      }


      void DataList_ItemCreated(Object sender , DataListItemEventArgs e ) {

		DataRowView myRowView;
		DataRow myRow;
		
		myRowView = (DataRowView) e.Item.DataItem;
		myRow = myRowView.Row;
		
		if  ( (int) myRow["OnSale"] == 0 ) 
			e.Item.FindControl("saleItem").Visible = false;
		
      }
  </script>

  <BODY BACKGROUND="images/back_sub.gif"> 
    <form runat="server">
    <FONT FACE="Verdana, Arial, Helvetica" SIZE=2>

      <TABLE BORDER=0>
        
        <tr>
          <td colspan=5>
            <IBA:Header id="Header" runat="server"/>
          </td>
        </tr>

        <TR>
          <TD ROWSPAN=5 ALIGN=LEFT VALIGN=TOP>

            <IBA:Categories id="Categories" runat="server"/>
            
            <br><br><br>
            
           
          </TD>
          
          <TD valign=top>
          
            &nbsp;&nbsp;&nbsp; <img id="CatalogueSectionImage" runat="server">
            <br><br>
          
            <asp:datalist id="MyList" BorderWidth=0 RepeatDirection=horizontal RepeatColumns=2 runat="server" OnItemCreated="DataList_ItemCreated">
          
              <itemtemplate>
              
                <table>
                  <tr>
                  
                    <td align=right valign=top width=150>
                      <IMG SRC='<%= Context.Request.ApplicationPath %>/images/<%#DataBinder.Eval(Container.DataItem, "ProductImageURL")%>'>
                    </td>
                  
                    <td width=20> </td>
                  
                    <td align=left valign=top>
                      <font size=2>
                      
                        <B>
                        <a href='Details.aspx?ProductCode=<%#DataBinder.Eval(Container.DataItem, "ProductCode")%>' style="color:black">
                          <%#DataBinder.Eval(Container.DataItem, "ProductName")%></a>
                        </B>,
                        <%#DataBinder.Eval(Container.DataItem, "ProductDescription")%><BR>

                        <BR>
                        
                          <%#DataBinder.Eval(Container.DataItem, "ProductCode")%>
                        </a>

                        <BR>
                        <BR> 
                        &nbsp; <img src="images/saleTag1.gif" id="saleItem" runat="server"  >

 

                        <B><%#DataBinder.Eval(Container.DataItem, "UnitPrice", "{0:C}")%></B>
                        
                        <br><br>
                        
                        <a href='<%# DataBinder.Eval(Container.DataItem, "ProductCode", "ShoppingCart.aspx?ProductCode={0}") %>'>
                          <img src="images/order.gif" WIDTH="55" HEIGHT="15" ALT="Order" BORDER=0>
                        </a>



                      </font>                      
                    </td>  
                  
                  </tr>
                </table>
              
              </itemtemplate>
          
            </asp:datalist>
            
          </TD>
        </TR>
        <TR><td>       <IBA:Footer runat="server" />
      </TABLE>
    </FONT>
    </form>
  </BODY>
</HTML>
